package haiyangwangwork.day11.homework.hk.牟丁西;

import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        //  输入7位同学的成绩，找出最高分，最低分(冒泡排序)
        Scanner input = new Scanner(System.in);
        double[] stuScore = new double[7];
        String[] stuName = new String[7];
        for (int i = 0; i < 7;i++){
            System.out.println("请输入学生姓名：");
            stuName[i] = input.next();
            System.out.println("请输入学生成绩：");
            stuScore[i] = input.nextDouble();
        }
        for (int i = 0;i < stuScore.length-1;i++){
            for (int j = 0;j < stuScore.length-i-1;j++){
                if (stuScore[i] < stuScore[j]){
                    double a = stuScore[j];
                    stuScore[j] = stuScore[j+1];
                    stuScore[j+1] = a;
                    String b = stuName[j];
                    stuName[j] = stuName[j+1];
                    stuName[j+1] = b;
                }
            }
        }
        double min = stuScore[0];
        double max = stuScore[stuScore.length-1];
        System.out.println("最高分的同学是" + stuName[stuName.length-1] + "分数为：" + max);
        System.out.println("最低分的同学是" + stuName[0] + "分数为：" + min);
    }
}
